package test;

import lombok.extern.slf4j.Slf4j;

import java.util.*;

/**
 * @author Seon
 * @date 2023/4/12
 */
@Slf4j
public class 新蜂推客科技面试 {
    public static void main(String[] args) {
        int[] testArray = {5,6,7,8,9,10};
//        List<String> testList = new ArrayList<>();
//        testList.add("123123123");
//        testList.add("123123123");
//        testList.add("123123123");
//        testList.add("123123123");
//        testList.add("123123123");
//        testList.add("123123123");
//        List<Integer> collect = testList.parallelStream().map(item -> {
//            int i = Integer.parseInt(item);
//            log.info("thrad id is {}", Thread.currentThread().getId());
//            return i;
//        }).collect(Collectors.toList());

        Solution solution = new Solution();
        solution.maxProductDifference(testArray);
        /**
         *         面试官考的mysql索引题目
         *         id, a,b,c
         *         id_index
         *         a index
         *         a->b->c_index
         *         a,b
         *         where c = y and a = z
         */

//        Arrays.stream(testArray).forEach(item -> {
//            log.info("thrad id is {}", Thread.currentThread().getId());
//        });

    }
    static class Solution {
        public int maxProductDifference(int[] nums) {
            Map<Integer, Integer> numberToIndex = new HashMap<>();

            for (int i = 0; i < nums.length; i ++) {

                numberToIndex.computeIfAbsent(nums[i], number -> number + 1);
//            numberToIndex.compute(nums[i], Integer::sum);
            }
            System.out.println(numberToIndex);
            int length = nums.length;

            Arrays.sort(nums);
//        System.out.println(numberToIndex.get(nums[length-1]));
//        System.out.println(numberToIndex.get(nums[length-2]));
//        System.out.println(numberToIndex.get(nums[1]));
//        System.out.println(numberToIndex.get(nums[0]));
            return (nums[length-1] * nums[length-2]) - (nums[1]*nums[0]);
        }
    }
}
